export const addPlanRules = {
    city: [{ required: true, message: '请选择投放城市', trigger: 'change' }],
    planName: [
        { required: true, message: '请填写方案名称', trigger: 'blur' },
        {
            validator: (rule, value, callback) => {
                const reg = /^[\w\d\u4e00-\u9fa5（）()\-_,*]{1,}$/gi;
                // if (/[/\\:*"<>| ?？》《：“”、\s]/gi.test(value)) {
                if (!reg.test(value)) {
                    // eslint-disable-next-line no-useless-escape
                    callback(new Error('方案名称支持文字、数字、大小写字母外，特殊符号只支持 （）()-_,*'));
                } else {
                    callback();
                }
            },
        },
    ],
    trade: [{ required: true, message: '请选择行业', trigger: 'change' }],
    saleType: [{ required: true, message: '请选择销售类型', trigger: 'change' }],
    beginDate: [{ required: true, message: '请选择开始日期', trigger: 'change' }],
    endDate: [{ required: true, message: '请选择结束日期', trigger: 'change' }],
    deliveryMode: [{ required: true, message: '请选择选点方式', trigger: 'change' }],
    seconds: [{ required: true, message: '请选择时长', trigger: 'change' }],
    numbers: [{ required: true, message: '请选择频次', trigger: 'change' }],
    screenType: [{ required: true, message: '请选择屏幕类型', trigger: 'change' }],
    compactNum: [{ required: true, message: '请填写签约点位数', trigger: 'blur' }],
    regulateNum: [{ required: true, message: '请填写调剂点位数', trigger: 'blur' }],

    photoUpReport: [{ required: true, message: '请选择上刊拍照方式', trigger: 'change' }],
    photoUp: [{ required: true, message: '请选择上刊是否带报', trigger: 'change' }],
    photoDownReport: [{ required: true, message: '请选择下刊拍照方式', trigger: 'change' }],
    photoDown: [{ required: true, message: '请选择下刊是否带报', trigger: 'change' }],

    mediaType: [{ required: true, message: '请选择媒体类型', trigger: 'change' }],
    guaranteAmout: [{ required: true, message: '请选择选点类型', trigger: 'change' }],

    xkPhotoNum: [
        { required: true, message: '请输入拍照数量', trigger: 'change' },
        {
            validator: (rule, value, callback) => {
                try {
                    const reg = /^[1-9]\d*$/;
                    if (!reg.test(value)) {
                        callback(new Error('请输入正确的格式'));
                    }

                    const num = parseInt(value);
                    if (1 <= num && num <= 15) {
                        callback();
                    } else {
                        callback(new Error('最大拍照15张'));
                    }
                } catch (error) {
                    callback(new Error('请输入正确的格式'));
                }
            },
        },
    ],
    skPhotoNum: [
        { required: true, message: '请输入拍照数量', trigger: 'change' },
        {
            validator: (rule, value, callback) => {
                try {
                    const reg = /^[1-9]\d*$/;
                    if (!reg.test(value)) {
                        callback(new Error('请输入正确的格式'));
                    }
                    const num = parseInt(value);
                    if (1 <= num && num <= 15) {
                        callback();
                    } else {
                        callback(new Error('最大拍照15张'));
                    }
                } catch (error) {
                    callback(new Error('请输入正确的格式'));
                }
            },
        },
    ],
};

export const perUploadPhtRules = {
    city: [{ required: true, message: '请选择城市', trigger: 'blur' }],
    beginDate: [{ required: true, message: '请选择投放开始日期', trigger: 'blur' }],
    planId: [{ required: true, message: '请选择方案', trigger: 'blur' }],
    imgType: [{ required: true, message: '请选择监拍类型', trigger: 'blur' }],
    machineNum: [{ required: true, message: '请输入点位编码', trigger: 'blur' },
    {
        validator: (rule, value, callback) => {
            const reg = /^[0-9a-zA-Z-]{1,}$/;
            // if (/[/\\:*"<>| ?？》《：“”、\s]/gi.test(value)) {
            if (!reg.test(value)) {
                // eslint-disable-next-line no-useless-escape
                callback(new Error('只支持字母数字或 - '));
            } else {
                callback();
            }
        },
    }

    ],
}
